import pika
from Scripts.headers import config


def conn(virtual=config.get('mq', 'jira_virtual_host'),
         user=config.get('mq', 'user'),
         password=config.get('mq', 'password'),
         ip=config.get('mq', 'ip'),
         port=config.get('mq', 'port')):
    auto = pika.PlainCredentials(user, password)

    conn_create = pika.BlockingConnection(pika.ConnectionParameters(host=ip,
                                                                    port=int(port),
                                                                    virtual_host=virtual,
                                                                    credentials=auto))
    # 声明队列，参数为队列名
    return conn_create.channel()
